<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org">
<head>
    <th:block th:include="include :: header('新增证件信息')"/>
    <th:block th:include="include :: select2-css"/>
</head>
<body>
<div class="main-content">
    <form id="form-certificate-edit" class="form-horizontal" AUTOCOMPLETE="OFF">
        <input name="id" type="hidden" id="id" th:value="${emergency.ID}"/>
        <h4 class="form-header h4">新增证件信息</h4>
        <div class="row">
            <div class="col-sm-6">
                <div class="form-group">
                    <label class="col-sm-4 control-label">证件类型：</label>
                    <div class="col-sm-8">
                        <select name="certtype" id="certtype" class="form-control m-b"
                                th:with="type=${@dict.getType('eCD_CertType')}">
                            <option value="">请选择</option>
                            <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:selected="${emergency.certtype+'' == dict.dictValue}"
                                    th:value="${dict.dictValue}"></option>
                        </select></div>
                </div>
            </div>
            <div class="col-sm-6">
                <div class="form-group">
                    <label class="col-sm-4 control-label">证件编号：</label>
                    <div class="col-sm-8">
                        <input name="certno" id="certno" th:value="${emergency.certno}" class="form-control" type="text"/>
                    </div>
                </div>
            </div>
        </div>
        <div class="row">
            <div class="col-sm-6">
                <div class="form-group">
                    <label class="col-sm-4 control-label">颁发机构：</label>
                    <div class="col-sm-8">
                        <input name="payOrg" id="payOrg"th:value="${emergency.payOrg}" class="form-control" type="text"/>
                    </div>
                </div>
            </div>
            <div class="col-sm-6">
                <div class="form-group">
                    <label class="col-sm-4 control-label">颁发日期：</label>
                    <div class="col-sm-8">
                        <input name="begindate" id="begindate"th:value="${emergency.begindate}" class="form-control laydate-demo-1" type="text"/>
                    </div>
                </div>
            </div>
        </div>

        <div class="row">
            <div class="col-sm-6">
                <div class="form-group">
                    <label class="col-sm-4 control-label">有效期：</label>
                    <div class="col-sm-8">
                        <input name="term" id="term"th:value="${emergency.term}" class="form-control" type="text"/>
                    </div>
                </div>
            </div>
            <div class="col-sm-6">
                <div class="form-group">
                    <label class="col-sm-4 control-label">截止日期：</label>
                    <div class="col-sm-8">
                        <input name="enddate" id="enddate"th:value="${emergency.enddate}" class="form-control laydate-demo-2" type="text"/>
                    </div>
                </div>
            </div>
        </div>

        <div class="row">
            <div class="col-sm-6">
                <div class="form-group">
                    <label class="col-sm-4 control-label">是否失效：</label>
                    <div class="col-sm-8">
                        <select name="isDisable" id="isDisable" class="form-control m-b">
                            <option value="">请选择</option>
                            <option value="0" th:selected="${emergency.isDisable == false}">有效</option>
                            <option value="1" th:selected="${emergency.isDisable == true}">失效</option>
                        </select></div>
                </div>
            </div>
        </div>
    </form>
</div>


<th:block th:include="include :: footer"/>
<th:block th:include="include :: select2-js"/>
<th:block th:include="include :: datetimepicker-js"/>

<script th:inline="javascript">

    var prefix = ctx + "entryManage/EntryBackground";

    $(function () {
        layui.use('laydate', function () {
            var laydate = layui.laydate;
            laydate.render({
                elem: '.laydate-demo-1',
                type: 'date'
            });
        });

        layui.use('laydate', function () {
            var laydate = layui.laydate;
            laydate.render({
                elem: '.laydate-demo-2',
                type: 'date'
            });
        });
    });

    function submitHandler() {
        if ($.validate.form()) {
            var data = $("#form-certificate-add").serializeArray();
            var id = $("#id").val();
            var certtype = $("#certtype").val();
            var certno = $("#certno").val();
            var payOrg = $("#payOrg").val();
            var begindate = $("#begindate").val();
            var term = $("#term").val();
            var enddate = $("#enddate").val();
            var isDisable = $("#isDisable").val();

            data.push({"name": "id", "value": id});
            data.push({"name": "certtype", "value": certtype});
            data.push({"name": "certno", "value": certno});
            data.push({"name": "payOrg", "value": payOrg});
            data.push({"name": "begindate", "value": begindate});
            data.push({"name": "term", "value": term});
            data.push({"name": "enddate", "value": enddate});
            data.push({"name": "isDisable", "value": isDisable});
            $.operate.save(prefix + "/editCertificate", data);
        }
    }


</script>
</body>
</html>
